1. Technical Field
The present invention is directed to a virtual mode virtual memory manager method and apparatus. More specifically, the present invention is directed to a virtual memory manager that operates using virtual memory rather than physical memory.
2. Description of Related Art
Operating systems are responsible for managing the virtual memory of a computer system. Virtual memory is addressable memory that extends beyond the limits of the available physical memory and is thus, “virtual.” The principal benefit of using virtual memory is that a user can run more applications at once and work with larger amounts of data than would be possible if the logical address space were limited to the available physical memory. Instead of equipping a computer with amounts of physical memory large enough to handle all possible needs, the user can install only enough physical memory to meet average needs. During those occasional times when more memory is needed for large tasks or many applications, the user can take advantage of virtual memory.
The operating system uses a Virtual Memory Manager (VMM) to perform virtual memory management. Virtual memory management involves the establishment of virtual address translations to real physical memory locations. The VMM also provides a number of routines that software can use to modify or obtain information about the software operations. For example, the VMM may be used to hold portions of the logical address space in physical memory, lock portions of the logical address space in their physical memory locations, determine whether a particular portion of the logical address space is currently in physical memory, and determine, from a logical address, the physical address of a block of memory.
The VMM extends the logical address space by using part of an available secondary storage, e.g., a hard disk, to hold portions of applications and data that are not currently in use in physical memory. When an application needs to operate on portions of memory that have been transferred to disk, the VMM loads those portions back into physical memory by making them trade places with other, unused segments of memory. This process of moving portions, or pages, of memory between physical RAM and the hard disk is called paging.
When a software component tries to access data in a page of memory that does not currently have a valid virtual to physical translation resident in the translation hardware, the CPU issues a special kind of bus error known as a page fault. Translation hardware is platform specific, but usually includes translation lookaside buffers and a hardware page table. The VMM intercepts page faults and tries to load the necessary translation into the hardware page table. In some cases not only does the referenced page not have a valid translation in the page table, but is also not resident in physical memory. In this case, not only does the VMM have to load a valid translation into the hardware page table, but it must also load the affected page or pages into physical memory. The VMM does so by executing its own internal page-fault handler.
Typically, the VMM operates in real mode, i.e. based on physical memory addresses, to avoid the potential catch-22 deadlock cases of needing to resolve a virtual memory fault, e.g., page fault, on behalf of itself. The problem with running the VMM in real mode is that it requires all data structures that it references to be in addressable contiguous physical memory. Several problems result due to this requirement.
First, the larger the physical memory configuration of a machine, the larger the data structures need to be to manage it. Thus, more and more addressable, contiguous physical memory is required as the memory size scales upwards. On partitionable systems, this presents a significant problem since only a portion of the physical address space is directly accessible to the operating system and that portion restricts the dynamic capabilities of the system such as for memory removal or addition.
Second, the data structures used to manage virtual memory can not be easily scaled smaller or larger. This is due to the requirement on physical addressability in the case of dynamic memory removal or addition. When relying on physical mode references to data structures, the structures which by definition are logically contiguous must then be physically contiguous in memory. The difficulty in scaling these data structures is that in order to dynamically grow one of them larger, the specific physical memory pages starting at the end of the currently sized data structure must be reclaimed for the contiguous growth of the structure.
Third, with Non-Uniform Memory Access (NUMA) systems, where the physical memory may be spread across multiple non-uniform access nodes, required physical addressability to these data structures results in the entire data structure residing in the memory of a single NUMA node. With NUMA systems, there is a performance cost associated with having to access memory of other nodes in the system. It is much more beneficial to be able to store portions of a data structure that is accessed by a node in local memory rather than having to access the data structure on another node's memory. Thus it is desirable to have the logically contiguous VMM data structures be physically discontiguous and distributed across the physical memory of each NUMA node.
Since all of the problems discussed above stem from the fact that VMM is run in real mode and thus, requires addressable contiguous physical memory, it would be beneficial to have a method and apparatus for running a VMM in virtual mode.